﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title>ECharts</title>
    <!-- 引入 echarts.js -->   
 
  <style>
    html,body { height:100%; width:100%; margin:0; padding:0;align:left;valign:left;}
  </style>
</head>
<body bgcolor="#000000">

    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
      <div id="main" style="width: 100%;height:100%;background-color:#000000;"></div>
   <!-- <div id="main" style="height:100%;width:100%;border:0px;background-color:#000000;"></div>-->
    <script src="./js/echarts.js"></script>
    <script type="text/javascript">      
       // var myChart = echarts.init(document.getElementById('main'));         
        var myChart;                
        //创建折线图
        function createYbChart(aa,cc){        	 
        	option = {
        		   
        		    tooltip : {
        		        trigger: 'item',
        		        formatter: "{a} <br/>{b} : {c} ({d}%)"
        		    },
        		    calculable : true,
        		    series : [
        		        {
        		            name:'不良类型',
        		            type:'pie',
        		            radius : '70%',
        		            itemStyle:{ 
        		                normal:{
        		                    label: {
        		                            show: true,
        		                            position:'outter',
        		                            textStyle:{
        		                               fontSize:18,
        		                               fontWeight: 'bolder'
        		                                }
        		                            }      
        		                       }
        		                     
        		                      },    
        		            center: ['50%', '50%'],
        		            data:cc
        		        }
        		    ]
        		};
         }
        
        function createChart(aa,bb){  
        	  //clear();
        	 myChart = echarts.init(document.getElementById('main'));        	
        	  // var cc = [{value:335, name:'直接访问'},{value:310, name:'邮件营销'},{value:234, name:'联盟广告'},{value:135, name:'视频广告'},{value:1548, name:'搜索引擎'}];
        	  var cc=new Array();
        	   for (x in aa)
        	   {          		   
        			 var obj=new  person();
        			 obj['name']=aa[x];
        			 obj['value']=bb[x];  
        			 cc[x]=obj;
        	     //document.write(aa[x] +":"+bb[x]+"<br />")
        	   }        	         	  
                createYbChart(aa,cc);                                
               myChart.setOption(option);
               window.onresize = myChart.resize;
        }  
        function person(value,name)
        {
            this.name=name;
            this.value=value;           
        }
        function clear(){
            myChart.clear();
        }

    </script>
</body>
</html>